package com.rmt.www.action;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.rmt.www.constant.RequestType;
import com.rmt.www.dao.ArtifactDao;
import com.rmt.www.dao.ProjectDao;
import com.rmt.www.dao.RequestDao;
import com.rmt.www.dao.UserDao;
import com.rmt.www.service.TestManageTestCaseService;
import com.rmt.www.utility.SystemTime;
import com.rmt.www.vo.Artifact;
import com.rmt.www.vo.Project;
import com.rmt.www.vo.Request;
import com.rmt.www.vo.TestArtifactRequest;
import com.rmt.www.vo.User;


public class UpdateTestSubmitAction extends ActionSupport{

	private static final long serialVersionUID = 1L;
	private int pid;
	private String testcasetype;
	private String title;
	private String priority;
	private String precondition;
	private String input;
	private String testdata;
	private String steps;
	private String expectedresult;
	private String postcondition;
	private String effort;
	private String cost;
	private String risk;
	private String comment;
	private int createrid;
	private Timestamp createdtime;
	private int updaterid;
	private Timestamp updatedtime;
	private int updatedtimes;
	private String version;
	private String status;
	private Integer aid;
	private String requestType;
	
	private TestManageTestCaseService testManageTestCaseService;
	
	public TestManageTestCaseService getTestManageTestCaseService() {
		return testManageTestCaseService;
	}


	public void setTestManageTestCaseService(
			TestManageTestCaseService testManageTestCaseService) {
		this.testManageTestCaseService = testManageTestCaseService;
	}


	public String execute(){
		TestArtifactRequest r = new TestArtifactRequest();
		r.setPid(pid);
		r.setTestartifactid(aid);
		r.setTestcasetype(testcasetype);
		r.setTitle(title);
		r.setPriority(priority);
		r.setPrecondition(precondition);
		r.setInput(input);
		r.setTestdata(testdata);
		r.setSteps(steps);
		r.setExpectedresult(expectedresult);
		r.setPostcondition(postcondition);
		r.setEffort(Integer.parseInt(effort));
		r.setCost(cost);
		r.setRisk(risk);
		r.setComment(comment);
		r.setUpdatedtimes(updatedtimes);
		r.setVersion(version);
		r.setStatus(status);
		r.setRequestType(RequestType.UPDATE);
		r.setCreaterid(createrid);
		r.setCreatedtime(createdtime);

		User u=(User)ActionContext.getContext().getSession().get("currentUser");
		r.setUpdaterid(u.getUid());
		r.setUpdatedtime(new java.sql.Timestamp(SystemTime.getSystemTime().getTime()));
		
		testManageTestCaseService.addNewTestCaseRequest(r);
		return "success";
		
	}


	public int getPid() {
		return pid;
	}


	public void setPid(int pid) {
		this.pid = pid;
	}


	public String getTestcasetype() {
		return testcasetype;
	}


	public void setTestcasetype(String testcasetype) {
		this.testcasetype = testcasetype;
	}


	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}


	public String getPriority() {
		return priority;
	}


	public void setPriority(String priority) {
		this.priority = priority;
	}


	public String getPrecondition() {
		return precondition;
	}


	public void setPrecondition(String precondition) {
		this.precondition = precondition;
	}


	public String getInput() {
		return input;
	}


	public void setInput(String input) {
		this.input = input;
	}


	public String getTestdata() {
		return testdata;
	}


	public void setTestdata(String testdata) {
		this.testdata = testdata;
	}


	public String getSteps() {
		return steps;
	}


	public void setSteps(String steps) {
		this.steps = steps;
	}


	public String getExpectedresult() {
		return expectedresult;
	}


	public void setExpectedresult(String expectedresult) {
		this.expectedresult = expectedresult;
	}


	public String getPostcondition() {
		return postcondition;
	}


	public void setPostcondition(String postcondition) {
		this.postcondition = postcondition;
	}


	public String getEffort() {
		return effort;
	}


	public void setEffort(String effort) {
		this.effort = effort;
	}


	public String getCost() {
		return cost;
	}


	public void setCost(String cost) {
		this.cost = cost;
	}


	public String getRisk() {
		return risk;
	}


	public void setRisk(String risk) {
		this.risk = risk;
	}


	public String getComment() {
		return comment;
	}


	public void setComment(String comment) {
		this.comment = comment;
	}


	public int getCreaterid() {
		return createrid;
	}


	public void setCreaterid(int createrid) {
		this.createrid = createrid;
	}


	public Timestamp getCreatedtime() {
		return createdtime;
	}


	public void setCreatedtime(Timestamp createdtime) {
		this.createdtime = createdtime;
	}


	public int getUpdaterid() {
		return updaterid;
	}


	public void setUpdaterid(int updaterid) {
		this.updaterid = updaterid;
	}


	public Timestamp getUpdatedtime() {
		return updatedtime;
	}


	public void setUpdatedtime(Timestamp updatedtime) {
		this.updatedtime = updatedtime;
	}


	public int getUpdatedtimes() {
		return updatedtimes;
	}


	public void setUpdatedtimes(int updatedtimes) {
		this.updatedtimes = updatedtimes;
	}


	public String getVersion() {
		return version;
	}


	public void setVersion(String version) {
		this.version = version;
	}


	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}

	public String getRequestType() {
		return requestType;
	}


	public void setRequestType(String requestType) {
		this.requestType = requestType;
	}


	public Integer getAid() {
		return aid;
	}


	public void setAid(Integer aid) {
		this.aid = aid;
	}
	
}
